<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"  import="my.dao.*" %>

<%
	
	String id=request.getParameter("e_id");
	String name=request.getParameter("e_name");
	String sex=request.getParameter("e_sex");
	String dep=request.getParameter("e_dep");


	String sql = 
		"select e.*,d.d_name "+
		"from emp e join dep d on e.e_dep=d.d_id "+
		"where 1=1";

	Object[] params=new Object[4];//存放参数的数组
	int size=0;//实际参数个数
	
	if(id != null && !id.equals("")){
		sql=sql+" and e_id like ? ";
		params[size++]="%"+id+"%";
	}
	
	if(name != null && !name.equals("")){
		sql=sql+" and e_name like ? ";
		params[size++]="%"+name+"%";
	}
	
	if(sex != null && !sex.equals("-1")){
		sql=sql+" and e_sex = ? ";
		params[size++]=sex;
	}
	
	if(dep != null && !dep.equals("-1")){
		sql=sql+" and e_dep = ? ";
		params[size++]=dep;
	}
	
	Object[] _params=new Object[size];
	for(int i=0;i<size;i++){
		_params[i]=params[i];
	}
	
	out.print(MyDao.queryJsonArray(sql,_params));
	
	
	
%>
